package com.it.service.impl;

import com.it.common.Result;
import com.it.dao.SongListMapper;
import com.it.domain.SongList;
import com.it.service.SongListService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SongListServImpl implements SongListService {

    @Autowired
    private SongListMapper songListMapper;

    @Override
    public Object AddSongList(SongList songlist) {

        SongList songList = songListMapper.SelectByTitle(songlist.getTitle().trim(),songlist.getListUserid());
        System.out.println(songlist.getListUserid());

        if(songList != null){
            return Result.fail("405","歌单存在");
        }
        else{
            if(songListMapper.AddSongList(songlist)>0){
                return Result.success("200","添加成功");
            }
            else {
                return Result.fail("406","添加失败");
            }
        }
    }

    @Override
    public boolean UpdateSongList(SongList songlist) {

        return songListMapper.UpdateSongList(songlist)>0;
    }

    @Override
    public boolean DeleteSongList(Integer id) {
        return songListMapper.DeleteSongList(id)>0;
    }

    @Override
    public List<SongList> SelectAll(Integer PageNum, Integer PageSize, String title) {
        return songListMapper.SelectAll(PageNum,PageSize,title);
    }

    @Override
    public Integer SelectTotal() {
        return songListMapper.SelectTotal();
    }

    @Override
    public SongList SelectById(Integer id) {
        return songListMapper.SelectById(id);
    }

    @Override
    public List<SongList> GetAll() {
        return songListMapper.GetAll();
    }

    @Override
    public SongList SelectSongList(String title, Integer userId) {
        return songListMapper.SelectSongList(title,userId);
    }

    @Override
    public List<SongList> SelectMainSongList(Integer[] ids) {
        return songListMapper.SelectMainSongList(ids);
    }

    @Override
    public List<SongList> getSongListSong(Integer SongListId) {
        return songListMapper.getSongListSong(SongListId);
    }

}
